<?php echo $this->render('layouts/__header.phtml'); ?>
<?php echo $this->render('layouts/__nav.phtml'); ?>

<link rel="stylesheet" type="text/css" href="/css/task.css" />
<script type="text/javascript" src="/js/color/selector.js"></script>
<script type="text/javascript">
window.addEvent('domready', function(){
	makeColorSelectors();
	$('savebtn').addEvent('click', function(e){
		e = new Event(e);
		config_validate('task_config_form');
		e.stop();
	});
	$('addlevelbtn').addEvent('click', function(e){
		e = new Event(e);
		var total = $ES('li','levelcolor').length;
		if (total > 10) {
			alert('Sorry too many levels !')
		} else {
			var level = document.createElement('li');
			level.style.background = '#ffffff';
			level.id = 'level_' + total + '_#ffffff';
			level.innerHTML = 'Level ' + total + ' (New)';
			$('level_list').appendChild(level);
			makeColorSelectors(level.id);
		}
		e.stop();
	});
	$('cleanbtn').addEvent('click', function(e){
		e = new Event(e);
		$('loadingbox').setStyle('display', 'block');
		var request_uri = '<?php echo $this->config_url;?>?clean=1&t='+(new Date()).getTime();
		new Ajax(request_uri, {
			method: 'get',
			onComplete: function(){
				if ('success' == this.response.text) {
					$('loadingbox').setStyle('display', 'none');
					alert('All cache has been cleaned!');
				}
			}
		}).request();
		
	});
});
</script>

	<form id="task_config_form" action="<?php echo $this->this_url; ?>" method="post">
	<input type="hidden" id="level" name="level" />
	<input type="hidden" id="save" name="save" />

	<h1>Task Configure</h1>
	<div id="configurebox">

		<div id="levelcolor">
			<ul id="level_list">
			<?php foreach ($this->level as $k => $v) : ?>
			<li id="level_<?php echo $k ?>_<?php echo $v ?>" style="cursor:pointer;background:<?php echo $v ?>">
			<?php echo ($k) ? 'Level '.$k : 'Default'; ?>
			</li>
			<?php endforeach; ?>
			</ul>
			<a id="addlevelbtn" href="javascript:;">Add New Level</a>
		</div>
		
		<div id="colorselector">
			<input type="text" id="color" class="color" value="#FFFF00"/>
		</div>
		
		<div id="confignotice"><font color="red">* Please click 'Enter' to choose task level color !</font></div>
		
		<div id="configbox">
			<table>
				<?php foreach ($this->config as $config) : ?>
				<tr>
					<td><?php echo $config['name']?>&nbsp;</td>
					<td><input type="text" name="<?php echo $config['name']?>" value="<?php echo $config['value']?>" /></td>
				</tr>
				<?php endforeach; ?>
				<tr>
					<td colspan="2" class="notice">
					<font color="red">* Please don not change the order of the old configures !</font>
					</td>
				</tr>
				<tr>
					<td colspan="2">
					<input type="button" id="savebtn" value="Save Configure" class="but" />
					<input type="button" id="cleanbtn" value="Clean Cache" class="but" />
					</td>
				</tr>
			</table>
		</div>

	</div>
	
	</form>

<div id="loadingbox" style="display:none;padding:2px 0px 0px 8px;width:125px;height:20px;text-align:center;position:absolute;top:0px;right:0px;background:#CC0000;color:#fff;z-index:10000;"><b>Loading ...</b></div>

<?php echo $this->render('layouts/__footer.phtml'); ?>